package com.yj.timecapsule.controller.comments;
import com.yj.timecapsule.common.response.CommonResponseType;
import com.yj.timecapsule.common.response.PageResponse;
import com.yj.timecapsule.entity.comments.dto.CommentDto;
import com.yj.timecapsule.entity.comments.dto.CommentPageDto;
import com.yj.timecapsule.entity.comments.vo.CommentsVo;
import com.yj.timecapsule.service.comments.CommentsService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comments")
public class CommentsController {
    @Resource
    private CommentsService commentsService;
    @GetMapping("/list")
    public CommonResponseType<PageResponse<CommentsVo>> list(CommentPageDto dto){
        return CommonResponseType.success(commentsService.list(dto));
    }
    @PostMapping
    public CommonResponseType<Object> comment(@RequestBody CommentDto commentDto){
        commentsService.comment(commentDto);
        return CommonResponseType.success();
    }

    @DeleteMapping("/del/{id}")
    public CommonResponseType<Object> del(@PathVariable("id") Long id){
        commentsService.del(id);
        return CommonResponseType.success();
    }
}
